package com.study.a01mycollection;

import java.util.ArrayList;
import java.util.Collection;

public class A01_CollectionDemo2 {
    public static void main(String[] args) {

        Collection<Student> coll = new ArrayList<>();

        Student s1 = new Student("张三", 18);
        Student s2 = new Student("李四", 22);
        Student s3 = new Student("王五", 17);

        coll.add(s1);
        coll.add(s2);
        coll.add(s3);


        Student s4 = new Student("张三", 18);
        //判断是否包含
        //contains()方法底层依赖的是equals()方法,需要地址值
        //重写equals方法后,可以比较内容
        boolean b = coll.contains(s4);
        System.out.println(b);


        //判断集合是否为空
        boolean empty = coll.isEmpty();
        System.out.println(empty);


        //集合的大小
        int size = coll.size();
        System.out.println(size);
    }
}
